﻿//
//
/////////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using FreeSpaceLibrary.XnaContentObjects;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

/////////////////////////////////////////////////////////////////////////////
namespace FreeSpaceLibrary
{
    /////////////////////////////////////////////////////////////////////////
    public class ContentLoader
    {
        private static Dictionary<TextureEnum, Texture2D> _contentTextures = new Dictionary<TextureEnum, Texture2D>();
        private static Dictionary<FontEnum, SpriteFont> _contentFonts = new Dictionary<FontEnum, SpriteFont>();
        private static ContentManager _content;

        /////////////////////////////////////////////////////////////////////
        public static Dictionary<TextureEnum, Texture2D> ContentTextures
        {
            get { return _contentTextures; }
        }

        /////////////////////////////////////////////////////////////////////
        public static Dictionary<FontEnum, SpriteFont> ContentFonts
        {
            get { return _contentFonts; }
        }

        /////////////////////////////////////////////////////////////////////
        public static void Load(ContentManager content)
        {
            _content = content;
            _contentTextures.Add(TextureEnum.BackgroundLevel1, content.Load<Texture2D>(@"Backgrounds\Background_level_1"));
            _contentTextures.Add(TextureEnum.BackgroundLevel2, content.Load<Texture2D>(@"Backgrounds\Background_level_2"));
            _contentTextures.Add(TextureEnum.AsteroidSmall1, content.Load<Texture2D>(@"Objects\Asteroids\asteroid_small_1"));
            _contentTextures.Add(TextureEnum.SpaceShip, content.Load<Texture2D>(@"Objects\SpaceShip\SpaceShip1"));
            _contentTextures.Add(TextureEnum.Weapon1, content.Load<Texture2D>(@"Objects\SpaceShip\Weapon1"));
            _contentTextures.Add(TextureEnum.Enemy1, content.Load<Texture2D>(@"Objects\Enemies\Enemy1"));
            _contentTextures.Add(TextureEnum.Enemy2, content.Load<Texture2D>(@"Objects\Enemies\Enemy2"));
            _contentTextures.Add(TextureEnum.Enemy3, content.Load<Texture2D>(@"Objects\Enemies\Enemy3"));

            _contentFonts.Add(FontEnum.LoadingCaption, content.Load<SpriteFont>(@"Fonts\Arial14"));
            _contentFonts.Add(FontEnum.MenuTitle, content.Load<SpriteFont>(@"Fonts\Arial14"));
            _contentFonts.Add(FontEnum.MenuItem, content.Load<SpriteFont>(@"Fonts\Arial12"));
        }

        /////////////////////////////////////////////////////////////////////
        public static ObjectData[] GetTargets()
        {
            return _content.Load<ObjectData[]>(@"Levels\Level1");
        }

        /////////////////////////////////////////////////////////////////////
        public static ObjectData[] GetTargetsByLevel(Levels level, SubLevels subLevel)
        {
            string levelFolderName = level.ToString().Substring("level".Length, level.ToString().Length - "level".Length);
            string sublevelFolderName = subLevel.ToString().Substring("SubLevel".Length, subLevel.ToString().Length - "SubLevel".Length);
            string t = String.Format(@"TargetLevels\{0}\{0}.{1}\{2}", levelFolderName, sublevelFolderName, "ObjectData");
            return _content.Load<ObjectData[]>(t);
        }
    }

/////////////////////////////////////////////////////////////////////////////
}//FreeSpace.Logic
